﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WPFServices.Models;
using WPFServices.Models.Domain;

namespace WPFServices.Services.DomainService.ProcessRouteinfo
{
    public class ProcessRouteService
    {
        private readonly ApiClient _apiClient;

        public ProcessRouteService()
        {
            _apiClient = new ApiClient();
        }

        /// <summary>
        /// 获取所有工艺路线
        /// </summary>
        public async Task<ApiPaging<List<ProcessRouteDto>>> SearchProcessRouteAsync(SearchProcessRouteDto searchProcessRouteDto)
        {
            var queryParams = $"PageIndex={searchProcessRouteDto.PageIndex}&PageSize={searchProcessRouteDto.PageSize}";


            var result = await _apiClient.GetAsync<ApiPaging<List<ProcessRouteDto>>>($"Process/GetProcessRoute?{queryParams}");
            if (result.IsSuc && result.code == ResultCode.Ok)
            {
                return result.data;
            }
            else
            {
                throw new Exception($"获取工艺路线列表失败: {result.msg}");
            }
        }
    }
}
